<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->string('open_id', 100)->nullable()->unique()->comment('微信OpenID');
            $table->string('union_id', 100)->nullable()->comment('微信UnionID');
            $table->string('nickname', 100)->nullable()->comment('微信昵称');
            $table->string('avatar_url', 255)->nullable()->comment('头像URL');
            $table->string('session_key', 100)->nullable()->comment('会话密钥');
            $table->boolean('is_active')->default(true)->comment('是否活跃');
            
            // 删除不需要的字段
            $table->dropColumn(['name', 'email', 'email_verified_at']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->string('name')->nullable();
            $table->string('email')->nullable()->unique();
            $table->timestamp('email_verified_at')->nullable();
            
            $table->dropColumn([
                'open_id',
                'union_id',
                'nickname',
                'avatar_url',
                'session_key',
                'is_active'
            ]);
        });
    }
};
